{include file="public/layout" /}

<body class="bodystyle" style="cursor: default; -moz-user-select: inherit; min-width: auto;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page ad" style="min-width: auto;">
    <div class="flexigrid">
        <div class="mDiv">
            <div class="ftitle">
                <h3>快递列表</h3>
                {eq name="$select" value="1"}
                <h5>(共 {$pageObj->totalRows} 个快递公司，已选中 {$selectNum} 个快递公司)</h5>
                {else/}
                <h5>(共{$pageObj->totalRows}条数据)</h5>
                {/eq}
            </div>
            <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>
            <form class="navbar-form form-inline" action="{:url('Shop/order_express')}" method="get" onsubmit="layer_loading('正在处理');">
                {$searchform.hidden|default=''}
                <input type="hidden" name="select" value="{$select}">
                <div class="sDiv">
                    <div class="sDiv2">
                        <input type="text" size="30" name="keywords" value="{$Request.param.keywords}" class="qsbox" placeholder="名称搜索...">
                        <input type="submit" class="btn" value="搜索">
                        <i class="iconfont e-sousuo"></i>
                    </div>
                </div>
            </form>
        </div>
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0" style="width: 100%">
                    <thead>
                        <tr>
                            <th axis="col1" class="w10">
                                <div class="tc"></div>
                            </th>
                            <th abbr="article_title" axis="col3" class="">
                                <div class="">
                                    快递名称 &nbsp; &nbsp; &nbsp;
                                    {eq name="$select" value="1"}
                                    <a href="JavaScript:void(0);" onclick="allSelect(1);">[全部选中]</a> &nbsp; &nbsp; &nbsp;
                                    <a href="JavaScript:void(0);" onclick="allSelect(0);">[全部取消]</a> &nbsp; &nbsp; &nbsp;
                                    {/eq}
                                </div>
                            </th>   
                            <th abbr="article_time" axis="col6" class="w150">
                                <div class="tc">快递标识</div>
                            </th>
                            {eq name="$select" value="1"}
                            <th axis="col1" class="w80">
                                <div class="tc">选中</div>
                            </th>
                            {else/}
                            <th axis="col1" class="w80">
                                <div class="tc">操作</div>
                            </th>
                            {/eq}
                            <th axis="col1" class="w80">
                                <div class="tc">排序</div>
                            </th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table style="width: 100%;">
                    <tbody>
                    {empty name="ExpressData"}
                        <tr>
                            <td class="no-data" align="center" axis="col0" colspan="50">
                                <div class="no_row">
                                    <div class="no_pic"><img src="__SKIN__/images/null-data.png"></div>
                                </div>
                            </td>
                        </tr>
                    {else/}
                        {foreach name="ExpressData" item="vo" key="k" }
                        <tr>
                            <td class="">
                                <div class="w10 tc"></div>
                            </td>
                            <td style="width: 100%;">
                                <div class="">{$vo.express_name}</div>
                            </td>
                            <td class="">
                                <div class="w150 tc">{$vo.express_code}</div>
                            </td>
                            {eq name="$select" value="1"}
                            <td>
                                <div class="w80 tc">
                                    {if condition="$vo['is_choose'] eq 1"}
                                        <span class="yes" onClick="changeTableVal('shop_express', 'express_id', '{$vo.express_id}', 'is_choose', this);"><i class="fa fa-check-circle"></i>是</span>
                                    {else /}
                                        <span class="no" onClick="changeTableVal('shop_express', 'express_id', '{$vo.express_id}', 'is_choose', this);"><i class="fa fa-ban"></i>否</span>
                                    {/if}
                                </div>
                            </td>
                            {else/}
                            <td>
                                <div class="w80 tc">
                                    <input type="hidden" id="express_name_{$vo.express_id}" value="{$vo.express_name}" />
                                    <input type="hidden" id="express_code_{$vo.express_id}" value="{$vo.express_code}" />
                                    <a class="btn blue" href="javascript:void(0);" onClick="parent.express(this, {$vo.express_id});"><i class="fa fa-location-arrow"></i>选择</a>
                                </div>
                            </td>
                            {/eq}
                            <td>
                                <div class="w80 tc">
                                    <input class="tc" type="text" onkeyup="this.value=this.value.replace(/[^\d]/g,'');" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onchange="changeTableVal('shop_express','express_id','{$vo.express_id}','sort_order',this);"  size="4"  value="{$vo.sort_order}" />
                                </div>
                            </td>
                        </tr>
                        {/foreach}
                    {/empty}
                    </tbody>
                </table>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        <!--分页位置-->
        {$pageStr}
    </div>
</div>

<script type="text/javascript">
    $(document).ready(function(){

        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function(){
            $(this).toggleClass('trSelected');
        });

        // 点击刷新数据
        $('.fa-refresh').click(function(){
            location.href = location.href;
        });
    });

    // 全部选中/全部取消
    function allSelect(is_choose) {
        var selectNum = "{$selectNum}";
        var totalRows = "{$pageObj->totalRows}";
        var msg = '';
        if (1 == is_choose) {
            if (selectNum == totalRows) {
                layer.msg('已全部选中，无需重复操作', {time: 2000});
                return false;
            }
            msg = '执行此操作则将 <span style="color: red;">' + totalRows + '</span> 个快递公司全部选中，是否确认？';
        } else {
            if (selectNum == 0) {
                layer.msg('已全部取消，无需重复操作', {time: 2000});
                return false;
            }
            msg = '执行此操作则将 <span style="color: red;">' + totalRows + '</span> 个快递公司全部取消选中，是否确认？';
        }
        layer.confirm(msg, {
            shade: layer_shade,
            area: ['480px', '190px'],
            move: false,
            title: '提示',
            btnAlign:'r',
            closeBtn: 3,
            btn: ['确定', '取消'] ,//按钮
            success: function () {
                  $(".layui-layer-content").css('text-align', 'left');
              }
        },function(){
            layer_loading('正在处理');
            $.ajax({
                url: "{:url('Shop/express_is_choose')}",
                data: {is_choose: is_choose, _ajax: 1},
                type:'post',
                dataType:'json',
                success:function(res) {
                    layer.closeAll();
                    if (1 == res.code) {
                        layer.msg(res.msg, {time: 1500}, function() {
                            window.location.reload();
                        });
                    } else {
                        layer.msg(res.msg, {time: 1500});
                    }
                }
            });
        });
    }
</script>

{include file="public/footer" /}